// 异步编程简洁示例

// 回调函数
function fetchWithCallback(callBack) {
    setTimeout(() => callBack("回调：数据加载完成"), 500);
}

// Promise
function fetchWithPromise() {
    return new Promise(resolve => setTimeout(() => resolve("Promise：数据加载完成"), 500));
}

// async/await
async function fetchWithAsync() {
    // 展示写await和不写await的区别
    const result = await fetchWithPromise();
    console.log(`Async/Await：${result}`);
}

// 调用示例
fetchWithCallback((e) => {
    console.log(`得到的返回值-1：${e}`)
});
fetchWithPromise().then((e) => {
    console.log(`得到的返回值-2：${e}`)
});
fetchWithAsync();